package com.cskaoyan.app.wxcontroller;

import com.cskaoyan.app.bean.common.BasePageInfo;
import com.cskaoyan.app.bean.common.BaseRespVo;
import com.cskaoyan.app.bean.common.CommonData;
import com.cskaoyan.app.bean.po.MarketTopic;
import com.cskaoyan.app.bean.vo.wx.TopicDetailVo;
import com.cskaoyan.app.wxservice.WxTopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//http://182.92.235.201:8083/wx/topic/detail?id=368
@RestController
@RequestMapping("wx/topic")
public class WxTopicController {
    @Autowired
    WxTopicService wxTopicService;

    @GetMapping("detail")
    public BaseRespVo detail(Integer id) {
        TopicDetailVo data = wxTopicService.detail(id);
        if ( data.getTopic().getDeleted()==true){
            BaseRespVo<Object> ok = BaseRespVo.invalidParameter("该条记录已被删除");
            return ok;
        }
        return BaseRespVo.ok(data);
    }

    //http://182.92.235.201:8083/wx/topic/related?id=368
    @GetMapping("related")
    public BaseRespVo related(Integer id) {
        CommonData<MarketTopic> data = wxTopicService.related(id);
        return BaseRespVo.ok(data);
    }

    //http://182.92.235.201:8083/wx/topic/list?page=1&limit=10
    @GetMapping("list")
    public BaseRespVo list(BasePageInfo basePageInfo){
        CommonData<MarketTopic> data=wxTopicService.list(basePageInfo);
        return BaseRespVo.ok(data);
    }


}
